#!/usr/bin/env python3
#-*- coding: utf-8 -*-

from abc import ABC,abstractclassmethod
import threading
class request(threading.Thread):
    @abstractclassmethod
    def __init__(self,connection,address,id,s_clients):
        '''
        Feature
            初始化
        Description
            初始化
        Args
            connection
                type:socket
                description:连接socket
            address
                type:ip address ("127.0.0.1",3000)
                description:ip地址和端口
            id
                type:int
                description:线程ID
        '''
        threading.Thread.__init__(self)
        self._connect=connection
        self._address=address
        self._id=id
        self._flag=threading.Event()
        self._flag.set()
        self._runing=threading.Event()
        self._runing.set()
        self._clients=s_clients
        self._status={}

    @abstractclassmethod
    def run(self):pass

    def stop(self):
        self._flag.clear()

    def resume(self):
        self._flag.set()

    def close(self):
        self._clients.pop(self._id)
        self._flag.set()
        self._runing.clear()

